package ru.gerunn.silent.common;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.ObjectInputStream;

import javax.net.ssl.SSLSocket;

import ru.gerunn.silent.message.Message;

public class SSLSocketReader implements Reader {

	BufferedReader bufferedReader;
	ObjectInputStream reader;

	public SSLSocketReader(SSLSocket socket) {
		try {
			this.bufferedReader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
			this.reader = new ObjectInputStream(socket.getInputStream());
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public Message read() {
		try {
			return (Message) this.reader.readObject();
		} catch (IOException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
		return null;
	}

}
